import { isHidden } from "vant/lib/utils";
import { createRouter, createWebHashHistory } from "vue-router";
const defRoutes = [
  {
    path: "/",
    redirect: "/login",
  },
  {
    name: "login",
    path: "/login",
    component: () => import("@/views/login/login.vue"),
  },
];
export const routes = [
  {
    path: "/home",
    name: "Home",
    redirect: "/comCenter",
    meta: { title: "系统首页", icon: "icon-xianxingtubiaozhizuomoban-47" },
    children: [
      {
        path: "/comCenter",
        component: () => import("@/views/home/comCenter.vue"),
        name: "ComCenter",
        meta: { title: "账户中心" },
      },
      {
        path: "/artDetail",
        isHidden: true,
        component: () => import("@/views/home/artDetail.vue"),
        name: "artDetail",
        meta: { title: "公告详情" },
      },
    ],
  },
  {
    path: "/flot",
    name: "flot",
    redirect: "/flotList",
    meta: { title: "船队管理", icon: "icon-gangwei" },
    children: [
      {
        path: "/flotList",
        component: () => import("@/views/flot/flotList.vue"),
        name: "flotList",
        meta: { title: "我的船队", icon: "icon-gangwei" },
      },
      {
        path: "/flotBoot",
        component: () => import("@/views/flot/flotBoot.vue"),
        name: "flotBoot",
        meta: { title: "我的船舶", icon: "icon-gangwei" },
      },
      {
        path: "/flotListAdd",
        isHidden: true,
        component: () => import("@/views/flot/flotList/flotListAdd.vue"),
        name: "flotListAdd",
        meta: { title: "船队新增", icon: "icon-gangwei" },
      },
      {
        path: "/flotListDetail",
        isHidden: true,
        component: () => import("@/views/flot/flotList/flotListDetail.vue"),
        name: "flotListDetail",
        meta: { title: "船队详情", icon: "icon-gangwei" },
      },

      {
        path: "/flotBootAdd",
        isHidden: true,
        component: () => import("@/views/flot/flotBoot/flotBootAdd.vue"),
        name: "flotBootAdd",
        meta: { title: "新增船舶", icon: "icon-gangwei" },
      },
      {
        path: "/flotBootDetail",
        isHidden: true,
        component: () => import("@/views/flot/flotBoot/flotBootDetail.vue"),
        name: "flotBootDetail",
        meta: { title: "船舶详情", icon: "icon-gangwei" },
      },
    ],
  },
  {
    path: "/sign",
    name: "sign",
    redirect: "/signList",
    meta: { title: "船员管理", icon: "icon-gangwei" },
    children: [
      {
        path: "/signList",
        component: () => import("@/views/sign/signList.vue"),
        name: "signList",
        meta: { title: "我的船员", icon: "icon-gangwei" },
      },
      {
        path: "/signListAdd",
        isHidden: true,
        component: () => import("@/views/sign/signListAdd.vue"),
        name: "signListAdd",
        meta: { title: "签约船员", icon: "icon-gangwei" },
      },
      {
        path: "/signListDetail",
        isHidden: true,
        component: () => import("@/views/sign/signListDetail.vue"),
        name: "signListDetail",
        meta: { title: "签约船员详情", icon: "icon-gangwei" },
      },
      {
        path: "/signDown",
        isHidden: true,
        component: () => import("@/views/sign/signDown.vue"),
        name: "signDown",
        meta: { title: "签约船员详情", icon: "icon-gangwei" },
      },
    ],
  },
  {
    path: "/work",
    name: "work",
    redirect: "/workList",
    meta: { title: "招募管理", icon: "icon-gangwei" },
    children: [
      {
        path: "/workList",
        component: () => import("@/views/work/workList.vue"),
        name: "workList",
        meta: { title: "发布招募", icon: "icon-gangwei" },
      },
      {
        path: "/workAdd",
        isHidden: true,
        component: () => import("@/views/work/workAdd.vue"),
        name: "workAdd",
        meta: { title: "发布招募详情", icon: "icon-gangwei" },
      },
    ],
  },
  {
    path: "/record",
    name: "record",
    redirect: "/recordList",
    meta: { title: "操作管理", icon: "icon-gangwei" },
    children: [
      {
        path: "/recordList",
        component: () => import("@/views/record/recordList.vue"),
        name: "recordList",
        meta: { title: "操作记录", icon: "icon-gangwei" },
      },
    ],
  },
];

const router = createRouter({
  history: createWebHashHistory(),
  routes: defRoutes.concat(routes),
});
router.beforeEach((to, from, next) => {
  if (from.query.page) {
    localStorage.setItem("boot_page", from.query.page);
  } else {
    localStorage.setItem("boot_page", 1);
  }
  next();
});

export default router;
